Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional tags to ASP.NET Core metrics #3247

Conversation

vishweshbankwar
Copy link
Member

Fixes #3083

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@vishweshbankwar vishweshbankwar marked this pull request as ready for review May 2, 2022 22:04
@vishweshbankwar vishweshbankwar requested a review from a team May 2, 2022 22:04
@codecov
Copy link

codecov bot commented May 2, 2022

Codecov Report

Merging #3247 (4b4fcbe) into main (95500ff) will increase coverage by 0.12%.
The diff coverage is 59.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3247      +/-   ##
==========================================
+ Coverage   85.36%   85.49%   +0.12%     
==========================================
  Files         261      261              
  Lines        9395     9410      +15     
==========================================
+ Hits         8020     8045      +25     
+ Misses       1375     1365      -10     
Impacted Files Coverage Δ
...AspNetCore/Implementation/HttpInMetricsListener.cs 65.71% <59.09%> (-19.29%) ⬇️
...ZPages/Implementation/ZPagesExporterEventSource.cs 56.25% <0.00%> (-6.25%) ⬇️
...metryProtocol/Implementation/ActivityExtensions.cs 91.81% <0.00%> (+3.44%) ⬆️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 82.35% <0.00%> (+5.88%) ⬆️
...tation/OpenTelemetryProtocolExporterEventSource.cs 85.00% <0.00%> (+10.00%) ⬆️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 77.27% <0.00%> (+18.18%) ⬆️
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 78.57% <0.00%> (+28.57%) ⬆️

Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


TagList tags;

#if NETCOREAPP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a net6.0 and netstandard2.1 build of this instrumentation. Does this directive apply to those targets?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now I'm wondering why we need a netstandard2.1 target given that we have a netcoreapp3.1 target.

Copy link
Member Author

@vishweshbankwar vishweshbankwar May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directive only applies to netcoreapp3.1 and net6.0. It does not apply to netstandard2.1or netstandard2.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment why this compiler directive is relevant. ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas - Added - Please review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have that information available during OnStop event.

Copy link
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Still curious if we need the netstandard2.x targets anymore, but that's unrelated to this PR.

{ SemanticConventions.AttributeHttpMethod, context.Request.Method },
{ SemanticConventions.AttributeHttpHost, host },
{ SemanticConventions.AttributeHttpTarget, target },
{ SemanticConventions.AttributeHttpStatusCode, context.Response.StatusCode },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Spec says this should be string, but I think StatusCode is an int here.

}
else
{
host = context.Request.Host.Host + ":" + context.Request.Host.Port;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a follow up - see if we avoid this string alloc, by using cache/other technique?

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM left couple of nits.
Please add to changelog.md as this is a noteworthy use-facing change.

{ SemanticConventions.AttributeHttpScheme, context.Request.Scheme },
{ SemanticConventions.AttributeHttpMethod, context.Request.Method },
{ SemanticConventions.AttributeHttpHost, host },
{ SemanticConventions.AttributeHttpStatusCode, context.Response.StatusCode.ToString() },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas cijothomas merged commit ee19d70 into open-telemetry:main May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ASP.NET Core metrics instrumentation attribute compliance
4 participants